/**
* @file demoiot_test_entry.c
* Copyright (c) 2020 HiSilicon (Shanghai) Technologies CO., LIMITED.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*     http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#include <stdio.h>
#include <unistd.h>
#include <unistd.h>

#include "ohos_init.h"
#include "ohos_types.h"

//#include "cmsis_os2.h"

#include <at.h>
#include "http_test.h"

#define UNUSED(var) do { (void)var; } while(0)

#if 0
void mqtt_test_thread(void * argv)
{
    argv = argv;
    mqtt_test();
}
#endif


hi_u32 demoiotHttpTest(hi_s32 argc, const hi_char **argv)
{
    UNUSED(argc);
    UNUSED(argv);

    #if 0
    osThreadAttr_t attr;

    attr.name = "wifi_config_thread";
    attr.attr_bits = 0U;
    attr.cb_mem = NULL;
    attr.cb_size = 0U;
    attr.stack_mem = NULL;
    attr.stack_size = 4096;
    attr.priority = 36;

    if (osThreadNew((osThreadFunc_t)mqtt_test_thread, NULL, &attr) == NULL) {
        printf("[LedExample] Falied to create LedTask!\n");
    }
    #else
    httpTestHttpGet();
    #endif

    AT_RESPONSE_OK;
    return HI_ERR_SUCCESS;
}

hi_u32 demoiotHttpsTest(hi_s32 argc, const hi_char **argv)
{
    UNUSED(argc);
    UNUSED(argv);

    httpTestHttpsGet();

    AT_RESPONSE_OK;
    return HI_ERR_SUCCESS;
}

static const at_cmd_func gDemoIoTCmdTbl[] = {
    {"+HTTP",  5, HI_NULL, HI_NULL, HI_NULL, demoiotHttpTest},
    {"+HTTPS", 6, HI_NULL, HI_NULL, HI_NULL, demoiotHttpsTest}
};

void demoiotTestEntry(void)
{
    hi_at_register_cmd(gDemoIoTCmdTbl, sizeof(gDemoIoTCmdTbl)/sizeof(gDemoIoTCmdTbl[0]));
}

SYS_RUN(demoiotTestEntry);
